package com.yingda.utils;

import com.yingda.bean.WorkBean;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorsUtils {

    private static ExecutorsUtils instance;
    private ExecutorService executorService;

    private ExecutorsUtils () {}

    public static ExecutorsUtils getInstance() {
        if (instance == null) {
            instance = new ExecutorsUtils();
        }
        return instance;
    }


    public void getSingleThread(Runnable runnable){
        executorService = Executors.newSingleThreadExecutor();
        executorService.execute(runnable);
    }

    public void closeThread(){
        if (executorService!=null){
            executorService.shutdown();
            executorService=null;
        }
    }
}
